package com.example.apitest;

import android.text.TextUtils;
import android.widget.Toast;

import androidx.recyclerview.widget.GridLayoutManager;

import com.example.apitest.adapter.MainAdapter;
import com.example.apitest.bean.MenuBean;
import com.example.apitest.databinding.ActivityManBinding;
import com.example.apitest.router.RouterControl;
import com.example.common.base.AbsActivity;
import com.example.common.utils.SPUtils;
import com.example.common.utils.SystemBrandUtils;
import com.example.im.utils.MessageUtils;
import com.example.stujava.module.xiangxue.annotation.Lable;

import java.util.ArrayList;
import java.util.List;

@Lable(tab = "VIP",number = 10)
public class MainActivity extends AbsActivity<ActivityManBinding> {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_man;
    }

    @Override
    protected void main() {
        init();
        initView();
        MessageUtils.getInstance().initIm();
    }

    private void init() {
//        CityDa dao = new CityDao();
//        if (dao.isEmpty()) {
//            dao.init(mContext);
//        }
    }

    @Override
    protected void initListener() {
//        ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
//        activityManager.getRunningTasks(1).get(0).topActivity
//                .getPackageName();

    }

    private void initView() {
        List<MenuBean> data = new ArrayList<>();
        data.add(new MenuBean("VIEW", R.mipmap.main_view));
        data.add(new MenuBean("TENCENT IM", R.mipmap.main_view));
        data.add(new MenuBean("System Element", R.mipmap.main_view));
        data.add(new MenuBean("kotlin", R.mipmap.main_view));
        data.add(new MenuBean("java", R.mipmap.main_view));
        data.add(new MenuBean("Jetpack", R.mipmap.main_view));
        data.add(new MenuBean("厂商", R.mipmap.main_view));
        mBinding.rv.setLayoutManager(new GridLayoutManager(this, 3));
        MainAdapter adapter = new MainAdapter(data);
        adapter.setOnItemClickListener((adapter1, view, position) -> {
            switch (position) {
                case 0:
                    RouterControl.jumpViewMain(this);
                    break;
                case 1:
                    if (TextUtils.isEmpty(SPUtils.getInstance().getStringValue(SPUtils.IM_LOGIN))) {
                        RouterControl.jumpImLogin(mContext);
                    } else {
                        RouterControl.jumpImMain(mContext);
                    }
                    break;
                case 2:
                    RouterControl.jumpElementMenu(mContext);
                    break;
                case 3:
                    RouterControl.jumpStuKotlin(mContext);
                    break;
                case 4:
                    RouterControl.jumpStuJava(mContext);
                    break;
                case 5:
                    RouterControl.jumpJetPack();
                case 6:
                    Toast.makeText(mContext, SystemBrandUtils.INSTANCE.getDeviceBrand(), Toast.LENGTH_SHORT).show();
            }

        });
        mBinding.rv.setAdapter(adapter);
    }

}